//
//  FinishOrderCell.m
//  zhiche--delivery
//
//  Created by LeeBruce on 16/5/27.
//  Copyright © 2016年 LeeBruce. All rights reserved.
//
#define buttonheight 30 * kHeight


#import "FinishOrderCell.h"
#import <Masonry.h>

@implementation FinishOrderCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self initSubviews];
    }
    
    return self;
}

-(void)initSubviews
{
      
    
//    __weak typeof(self) weakSelf = self;
    self.detailButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.lastView addSubview:self.detailButton];
    
    [self.detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(7 * kWidth);
        make.right.mas_offset(-14);
        make.size.mas_offset(CGSizeMake(71 * kWidth, buttonheight));
        
    }];
    
    [self.detailButton setTitle:@"查看详情" forState:UIControlStateNormal];
    [self.detailButton setTitleColor:WhiteColor forState:UIControlStateNormal];
    self.detailButton.titleLabel.font = Font(14);
    self.detailButton.backgroundColor = YellowColor;
    self.detailButton.layer.cornerRadius = 5;
    
//    UILabel *label = [[UILabel alloc]init];
//    [self.contentView addSubview:label];
//    [label mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.right.mas_equalTo(weakSelf.detailButton.mas_left).offset(0);
//        make.size.mas_offset(CGSizeMake(0.5, 34));
//        make.top.equalTo(weakSelf.detailButton);;
//        
//    }];
//    label.backgroundColor = GrayColor;
}

-(void)setModel:(MineOrderModel *)model
{
    if (_model != model) {
        
        /*
        //订单号
        self.orderNumberL.text = [NSString stringWithFormat:@"%@",model.waybillCode];
        //起始地
        
        if ([model.loadProvince isEqualToString:model.loadCity]) {
            
            self.startAddress.text = [NSString stringWithFormat:@"%@",model.loadProvince];
            
        } else {
            self.startAddress.text = [NSString stringWithFormat:@"%@-%@",model.loadProvince,model.loadCity];
            
        }

        
        //状态
        self.statusLabel.text = [NSString stringWithFormat:@"%@",model.statusText];
        
        //起始时间
        
        self.startTimeL.text = [NSString stringWithFormat:@"%@",model.loadTime];
        //终止地
        
        if ([model.unloadProvince isEqualToString:model.unloadCity]) {
            
            self.endAddress.text = [NSString stringWithFormat:@"%@",model.unloadProvince];
            
        } else {
            self.endAddress.text = [NSString stringWithFormat:@"%@-%@",model.unloadProvince,model.unloadCity];
            
        }

        
//        self.endAddress.text = [NSString stringWithFormat:@"%@-%@",model.unloadProvince,model.unloadCity];
        
        //终止日期
        self.endTimeL.text = [NSString stringWithFormat:@"%@",model.unloadTime];
        
        //车
        NSMutableArray *array = [NSMutableArray array];
        self.carStyleL.text = @"";
        
        for (int i = 0; i < model.vehicles.count; i ++) {
            NSString *string = [NSString stringWithFormat:@"%@-%@-%@辆",model.vehicles[i][@"brandName"],model.vehicles[i][@"vehicleName"],model.vehicles[i][@"amount"]];
            
            self.carStyleL.text = [self.carStyleL.text stringByAppendingString:string];
            self.carStyleL.text = [self.carStyleL.text stringByAppendingString:@"   "];
            
            [array addObject:string];
            
        }
        
        [self.carStyleL sizeToFit];
        self.carStyleL.frame = CGRectMake(self.carStyleL.frame.origin.x, self.carStyleL.frame.origin.y, self.carStyleL.frame.size.width, cellHeight);
        
        self.scroll.contentSize = CGSizeMake(self.carStyleL.frame.size.width, cellHeight);
        
         */
        
    }
}


-(NSString *)backDateWithString:(NSString *)string
{
    NSDate *nd = [NSDate dateWithTimeIntervalSince1970:[string integerValue]/1000];
    
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"yyyy-MM-dd"];
    NSString *dateString = [dateFormat stringFromDate:nd];
    
    return dateString;
}



@end
